﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/**
 * 创建时间：2015/1/13 10:53:22
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.App.Views.CacheManage
{
    public class CacheQueueAssistantSingleton
    {
        private static CacheQueueAssistantSingleton instance = null;

        private static CacheQueueAssistant cacheQueueAssistant = null;
        private static bool IsRunning = true;
        private static bool IsLoadNetData = true;
        //程序运行时创建一个静态只读的辅助对象  
        private static readonly object syncRoot = new object();

        private CacheQueueAssistantSingleton() { }

        public static CacheQueueAssistantSingleton Instance()
        {
            //第一重判断，先判断实例是否存在，不存在再加锁处理  
            if (instance == null)
            {
                //加锁的程序在某一时刻只允许一个线程访问  
                lock (syncRoot)
                {
                    //第二重判断  
                    if (instance == null)
                    {
                        instance = new CacheQueueAssistantSingleton();  //创建单例实例                          
                        cacheQueueAssistant = new CacheQueueAssistant();
                        IsRunning = false;
                        IsLoadNetData = false;
                    }
                }
            }
            return instance;
        }

        public CacheQueueAssistant InitCacheQueueAssistant()
        {
            return cacheQueueAssistant;
        }

        public bool GetIsRunning()
        {
            return IsRunning;
        }

        public void SetIsRunning(bool isRunning)
        {
            IsRunning = isRunning;
        }

        public bool GetIsLoadNetData()
        {
            return IsLoadNetData;
        }

        public void SetIsLoadNetData(bool isLoadNetData)
        {
            IsLoadNetData = isLoadNetData;
        }

    }

}
